package com.sjlh.centurylianhua.controller;

import com.sjlh.centurylianhua.entity.RefundLog;
import com.sjlh.centurylianhua.mapper.RefundLogMapper;
import com.sjlh.centurylianhua.utils.ResultData;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;

@CrossOrigin
@RestController
@RequestMapping("/refund")
public class RefundController {

    @Resource
    private RefundLogMapper refundLogMapper;
    /**
     * 添加退货日志
     * */
    @RequestMapping("/add")
    public ResultData addRefund(@RequestBody RefundLog refundLog){
        refundLog.setStandby1("SJLH"+new Date().getTime()+"M");
        int insert = refundLogMapper.insert(refundLog);
        long id=refundLog.getId();
        if (insert==1)
            return new ResultData(true,20000,"添加成功",true,id);
        else
            return new ResultData(false,20001,"添加失败",false,null);
    }

}
